/**
 * 
 */
package com.res.simulator.transformer;

import java.util.HashMap;
import java.util.Map;

import com.res.common.transformer.BaseTransformer;
import com.res.simulator.model.WADLScanModel;
import com.res.simulator.view.WADLDataView;
import com.sip.dbadapter.dao.domain.ReleaseVersion;
import com.sip.dbadapter.dao.domain.SystemInfo;
import com.sip.dbadapter.domain.registry.DomainRegistry;

/**
 * @author Dhanushka Ariyasingha.
 * 
 */
public class WADLScanTransformer implements BaseTransformer<WADLScanModel, WADLDataView, Map<String, Object>> {

	public Map<String, Object> transformModelToDomian(final WADLScanModel model) throws Exception {
		// TODO Auto-generated method stub

		final ReleaseVersion releaseVersion = new ReleaseVersion();
		final SystemInfo systemInfo = new SystemInfo();

		releaseVersion.setName(model.getReleaseName());
		releaseVersion.setUrl(model.getUrl());

		systemInfo.setSystemName(model.getSystemName());

		final Map<String, Object> domainCollection = new HashMap<String, Object>();
		domainCollection.put(DomainRegistry.RELEASE_VERSION, releaseVersion);
		domainCollection.put(DomainRegistry.SYSTEM_INFO, systemInfo);

		return domainCollection;
	}

	public WADLDataView transformDomianToView(final Map<String, Object> domainCollection) throws Exception {
		// TODO Auto-generated method stub

		final WADLDataView view = new WADLDataView();

		final String apiCount = (String) domainCollection.get("NO_OF_API");
		final String releaseNumber = (String) domainCollection.get("RELEASE_NO");
		final String systemName = (String) domainCollection.get("SYSTEM_NAME");

		view.setNumberOfAPI(apiCount);
		view.setReleaseId(releaseNumber);
		view.setSystemName(systemName);

		return view;
	}

}